let s = "abcdefg", k = 2
var reverseStr = function(s, k) {
    let n = s.length
    s = Array.from(s)
    for(let i=0;i<n;i+=2*k){
        let end = (i+k)<n?(i+k-1):(n-1)
        s = fzhs(i,end,s)
    }
    s = s.join('')
    return s
};
  function fzhs(start,end,s){
    
    while(start<end){
        let mid = s[start]
        s[start] = s[end]
        s[end] = mid 
        start++
        end--
    }
    
    return s
  }

console.log(  reverseStr(s,k));

  